package cn.kgc.common.controller;

import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class CommonController {

    @GetMapping({"/","/index"})
    public String index(){
        return "index";
    }

    @Secured("ROLE_normal")
    @GetMapping("/p1")
    public String p1(){
        return "p1";
    }

    //@Secured("ROLE_normal")

    @PreAuthorize("hasAnyRole('order')")
    @GetMapping("/p2")
    public String p2(){
        return "p2";
    }

    //@Secured("ROLE_order")
    @PreAuthorize("hasAnyRole('normal')")
    @GetMapping("/p3")
    public String p3(){
        return "p3";
    }

    @GetMapping("/403")
    public String p403(){
        return "403";
    }
}
